﻿var cmpo;
var cmpstat=0;
function cmp_loaded(key) {
    //cmp loaded
    cmpo = window.document["os_musicplayer_swf"];
	if (cmpo) {
		//cmp callback
		//alert(cmpo.config('version'));
	    //document.title = cmpo.config('name');
	    document.getElementById("iBtn_play_contrl").style.display = "";
	    cmpo.addEventListener('model_load', 'cmp_model_load');
	    cmpo.addEventListener('model_state', 'cmp_model_state');
	    
	}
}
function cmp_play() {
    
    if (cmpstat == 1) {
        
        cmpo.sendEvent("view_pause");
    }
    else {
        cmpo.sendEvent("view_play");
    }
    

}

function cmp_model_load(data) {
    
    document.getElementById("play_songname").innerHTML = cmpo.item('label');
	
}

function cmp_model_state(data) {
    
    //alert(data);
    var t = "";
    var cmpstat = 1;
    var stat = "";
    stat = data;
    //alert(stat);
    switch (stat)
    {
        case "undefined":
            t = "未知错误";
            break;
        case "connecting":
            t = "连接中";
            break;
        case "buffering":
            t = "缓冲中";
            break;
        case "playing":
            t = "正在播放";
            break;
        case "paused":
            t = "暂停";
            cmpstat = 0;
            break;
        case "stopped":
            t = "已停止";
            cmpstat = 0;
            break;
        case "completed":
            t = "播放完成";
            break;
        case "reconnecting":
            t = "重试连接";
            break;
        default:
            t = "";
            break;
    }
    
    
    if (cmpstat == 0) {
        document.getElementById("iBtn_play").className = "iBtn_pause";
    }
    else {
        document.getElementById("iBtn_play").className = "iBtn_play";
    }
    document.getElementById("play_status").innerHTML = "["+t+"]";

}